import threading
import select
import socket
+import fcntl
from errno import EAGAIN, EINTR, EWOULDBLOCK
def createSocket(self):
raise NotImplementedError()
+ def setCloExec(self):
+ fcntl.fcntl(self.sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC)
+
def acceptConnection(self, sock, protocol, addr):
return SocketServerConnection(sock, protocol, addr, self)
#============================================================================
from unix import listenUNIX, connectUNIX
-from tcp import listenTCP, connectTCP
+from tcp import listenTCP, connectTCP, SetCloExec
l.startListening()
return l
+def SetCloExec(SocketListener):
+ SocketListener.SetCloExec()
+
def connectTCP(host, port, factory, timeout=None, bindAddress=None):
c = TCPConnector(host, port, factory, timeout=timeout, bindAddress=bindAddress)
c.connect()
DBVar('restart_time', ty='float'),
DBVar('restart_count', ty='int'),
DBVar('target', ty='long', path="memory/target"),
+ DBVar('device_model_pid', ty='int'),
]
def __init__(self, db):
self.vcpus = 1
self.vcpusdb = {}
self.bootloader = None
+ self.device_model_pid = 0
def setDB(self, db):
self.db = db
sxpr.append(devs)
if self.config:
sxpr.append(['config', self.config])
+ if self.device_model_pid:
+ sxpr.append(['device_model_pid',self.device_model_pid])
return sxpr
def sxpr_devices(self):
ctrl.initController(reboot=True)
else:
self.create_configured_devices()
- self.image.createDeviceModel()
+ if not self.device_model_pid:
+ self.device_model_pid = self.image.createDeviceModel()
def device_create(self, dev_config):
"""Create a new device.
memmap = None
memmap_value = []
device_channel = None
-
+ pid = 0
def createImage(self):
"""Create a VM for the VMX environment.
"""
log.info("spawning device models: %s %s", device_model, args)
self.pid = os.spawnve(os.P_NOWAIT, device_model, args, env)
log.info("device model pid: %d", self.pid)
+ return self.pid
def vncParams(self):
# see if a vncviewer was specified
def destroy(self):
channel.eventChannelClose(self.device_channel)
import signal
+ if not self.pid:
+ self.pid = self.vm.device_model_pid
os.kill(self.pid, signal.SIGKILL)
(pid, status) = os.waitpid(self.pid, 0)
+ self.pid = 0
def getDomainMemory(self, mem_mb):
# for ioreq_t and xenstore
if xroot.get_xend_relocation_server():
port = xroot.get_xend_relocation_port()
interface = xroot.get_xend_relocation_address()
- reactor.listenTCP(port, factory, interface=interface)
+ l = reactor.listenTCP(port, factory, interface=interface)
+ l.setCloExec()
def setupRelocation(dst, port):
try: